<?php

class Thanhvien_vaitro extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->model('');
    }

    public function index($vaitro) {
        
    }

    public function xacnhan_phanloai() {

        $session_data = $this->session->userdata('logged_in');
        $id=$session_data['id'];
        $phanloai_id = $this->input->post('phanloai_id');

        //$this->load->model('thanhvien_trangthai_model');
        //$trangthai=$this->thanhvien_trangthai_model->load_trangthai_from_thanhvien($id);

        $this->load->model('thanhvien_phanloai_model');
        //$is_set=$phanloai=$this->thanhvien_phanloai_model->load_phanloai_from_thanhvien($id);
        $phanloai_ten = $this->thanhvien_phanloai_model->load_phanloai($phanloai_id);

        /*
          $data['phanloai_same'] = FALSE;
          if ($is_set==TRUE)
          {
          $data['phanloai_ten_indata']=$phanloai->ten;
          if ($phanloai_id!=$phanloai->id) {
          $data['phanloai_same'] = FALSE;
          } else {
          $data['phanloai_same'] = TRUE;
          }
          }
          $data['trangthai']=$trangthai->ten;
          if ($trangthai->id == 2) {
          $data['not_allow'] = FALSE;
          } else {
          $data['not_allow'] = TRUE;
          } */


        $data['result'] = $phanloai_ten;
        $data['phanloai_id'] = $phanloai_id;

        $this->load->view('user/thanhvien/submit_phanloai', $data);
    }

    public function change_phanloai() {
        $session_data = $this->session->userdata('logged_in');
        $id=$session_data['id'];
        $data = array(
            'phanloai_id' => $this->input->post('phanloai_id')
        );
        $this->db->update('gs7s_thanhvien', $data, array('id' => $id));
        redirect('/thanhvien/thanhvien_diachi/load_diachi/' . $id);
    }

}
